package memleak.test.com.testlist;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.gzgd.log.LogUtils;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    protected static String TAG = "MainActivity";
    private LeftLayout mlayout;


    public VideoBean mCurVideoBean; //记录当前播放的节目
    private PreferencesDataSource mPreferenceDataSource;

    static  MainActivity  inst = null;

    static  public  MainActivity  getinstace(){
                return  inst ;
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        mPreferenceDataSource = PreferencesDataSource.newInstance();
        mPreferenceDataSource.init(this);

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mlayout = (LeftLayout) findViewById(R.id.leftLayout);
        inst = this;




    }

    private List<ChannelCategory>      init(){

        List<LiveChannel> channels = new ArrayList<>();
        channels.add(new LiveChannel("1","123","http://22"," ","1","1","1","1","1"));
        channels.add(new LiveChannel("1","234","http://22"," ","2","1","1","1","1"));
        channels.add(new LiveChannel("1","345","http://22"," ","3","1","1","1","1"));
        channels.add(new LiveChannel("1","456","http://22"," ","4","1","1","1","1"));

        List<ChannelCategory>   cc  = new ArrayList<>();
        cc.add(new ChannelCategory("高清","1",channels));

        List<LiveChannel> channels2 = new ArrayList<>();
        channels.add(new LiveChannel("2","a123","http://22"," ","5","1","1","1","1"));
        channels.add(new LiveChannel("2","a234","http://22"," ","6","1","1","1","1"));
        channels.add(new LiveChannel("2","a345","http://22"," ","7","1","1","1","1"));
        channels.add(new LiveChannel("2","a456","http://22"," ","8","1","1","1","1"));

        cc.add(new ChannelCategory("APP","1",channels2));

         return  cc;

    }

    // public void updateView(List<ChannelCategory> channelCategories)

    @Override
    protected void onResume() {
        super.onResume();
        mlayout.updateView(init());

    }

    public void changePagePos(int position) {
        LogUtils.d(TAG, "changePagePosTo:" + position);
        mlayout.setPagePos(position);
    }


    public void changeChannelPos(int position) {

        mlayout.setChannelPos(position);
    }

    public int getPagePos() {
      return mlayout.getPagePos();
    }
    public VideoBean getCurVideoBean() {
        return mCurVideoBean;
    }

    public int getChannelPos() {
        return mlayout.getChannelPos();
    }
    public int getPrePagePos() {
        return mlayout.getPrePagePos();
    }

    public int getPreChannelPos() {
        return mlayout.getPreChannelPos();
    }
    public String getCategoryId() {
        return mlayout.getCurCategoryId();
    }
}
